/** * 审核页面 */
<template>
  <view>
    <u-subsection
      :list="list"
      :current="current"
      :animation="true"
      mode="button"
      font-size="30"
      @change="change"
      button-color="#2979FF"
      active-color="#ffffff"
    ></u-subsection>
    <u-card
      :title="item.name"
      :sub-title="item.createTime + ' ' + item.applyer"
      v-for="(item, index) in taskList"
      :key="index"
      @click="gotoDetail(item)"
    >
      <view class="" slot="body">
        <view>
          <view class="u-font-25">
            <view class="u-body-item-title u-line-2">{{
              item.title || "无"
            }}</view>
          </view>
        </view>
      </view>
    </u-card>
  </view>
</template>

<script>
// 引入封装好的网络请求
import auditApi from "../../api/audit.js";
import { http } from "@/common/service.js";
export default {
  mounted() {
    this.token = this.$store.state.token;
    this.getTaskList();
  },
  data() {
    return {
      // 搜索框双向绑定
      keyword: "",
      // tab栏列表
      list: [
        {
          name: "待办",
        },
        {
          name: "已办",
        },
      ],
      token: "",
      // 审核列表
      taskList: [],
      current: 0,
      title: "素胚勾勒出青花，笔锋浓转淡",
      subTitle: "2020-05-15",
      thumb: "http://pic2.sc.chinaz.com/Files/pic/pic9/202002/hpic2119_s.jpg",
    };
  },
  methods: {
    getTaskList() {
      switch (this.current) {
        case 0:
          auditApi
            .getTodoList({
              "X-Access-Token": this.$store.state.token,
            })
            .then((res) => {
              console.log(res);
              this.taskList = res.data.result;
            });
          break;
        case 1:
          auditApi
            .getDoneList({
              "X-Access-Token": this.$store.state.token,
            })
            .then((res) => {
              console.log(res);
              this.taskList = res.data.result;
            });
          break;
        default:
          break;
      }
    },
    change(index) {
      this.current = index;
      this.getTaskList();
    },
    // 跳转到详情页面的回调函数
    gotoDetail(item) {
      for (const key in item) {
        if (item[key] === null || item[key] === undefined) {
          item[key] = "";
        }
      }
      this.$Router.push({
        path: "/pages/auditDetail/auditDetail",
        query: { obj: item, current: this.current },
      });
    },
  },
};
</script>

<style lang="scss">
.u-card-wrap {
  background-color: $u-bg-color;
  padding: 1px;
}

.u-body-item {
  font-size: 32rpx;
  color: #333;
  padding: 20rpx 10rpx;
}

.u-body-item image {
  width: 120rpx;
  flex: 0 0 120rpx;
  height: 120rpx;
  border-radius: 8rpx;
  margin-left: 12rpx;
}
</style>
